package com.itheima.web.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author shkstart
 * @create 2020-08-02 17:53
 */
@Controller
@RequestMapping("/user")
@ResponseBody
public class UserController {

    @Autowired
    private UserService userService;

    /*
    * 查询所有用户
    * */
    @RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }


    /*
    * 根据id查询用户
    * */
    @RequestMapping("/findById")
    public User findById(Integer id){
    return userService.findById(id);
    }

    /*
    * 更新用户
    * */
    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        userService.Update(user);

    }
}
